<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>添加会议纪要-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.wbai{ width:100%; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">会议纪要 > 添加会议纪要</div>
	</div>
	<div id="content">
		<form action="__APP__/Index/meeting_minutes_add" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="add">
			<div class="form-main">
				<div class="form-title">添加会议纪要</div>
				<div class="form-item clearfix">
					<div class="item-float">
						<div class="input-label"><span class="asterisk">*</span>所属中心</div>
						<div class="input-item">
							<if condition="get_permission('HY',NULL,1)">
							<select name="center_id" class="form-control select-add" autocomplete="off">
								<option value="-10" selected>请选择</option>
								<foreach name="center_list" item="vo">
									<option value="{$vo['id']}">{$vo['first_name']}</option>
								</foreach>
							</select>
							<span class="error-item">必填项</span>
							<else/>
								{$center_name}
								<input type="hidden" name="center_id" class="project_type" value="{$login_center_id}">
							</if>
						</div>
					</div>
					<div class="item-float">
						<div class="input-label"><span class="asterisk">*</span>关联会议纪要</div>
						<div class="input-item">
							<select name="hy_id" class="form-control" autocomplete="off">
								<option value="-10" selected>请选择</option>
							</select>
						</div>
					</div>
				</div>
				<div class="form-item clearfix">
					<div class="item-float">
						<div class="input-label"><span class="asterisk">*</span>会议模板</div>
						<div class="input-item">
							<if condition="get_permission('HY',NULL,1)">
							<select name="mb_id" class="form-control select-add" autocomplete="off">
								<option value="-10">请先选择所属中心</option>
							</select>
							<else/>
								<select name="mb_id" class="form-control select-add" autocomplete="off">
									<option value="-10">请选择</option>
									<foreach name="module" item="vo">
										<option value="{$vo['id']}">{$vo['module_name']}</option>
									</foreach>
								</select>
							</if>
							<span class="error-item">必填项</span>
						</div>
					</div>
					<div class="item-float">
						<div class="input-label"><span class="asterisk">*</span>编号</div>
						<div class="input-item">
							<span class="data_num"></span>
							<input type="hidden" name="meeting_num">
						</div>
					</div>
				</div>
				<div class="form-item clearfix">
					<div class="item-float">
						<div class="input-label"><span class="asterisk">*</span>会议日期</div>
						<div class="input-item">
							<input name="date" type="text" class="form-control Wdate required-text w100" onclick="WdatePicker()" readonly="" autocomplete="off">
							<span class="error-item">必填项</span>
						</div>
					</div>
					<div class="item-float">
						<div class="input-label"><span class="asterisk">*</span>会议地点</div>
						<div class="input-item">
							<input type="text" name="meeting_address" class="form-control required-text" autocomplete="off">
							<span class="error-item">必填项</span>
						</div>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"></div>
					<div class="input-item">
						<a class="btn click_btn">点击生成与会人员</a>
					</div>
				</div>
				<div class="pep_cont hide">
					<div class="form-item">
						<div class="input-label"><span class="asterisk">*</span>与会人员</div>
						<div class="input-item">
							<button type="button" class="is_all btn is_all_btn">选择用户</button>
							<span class="error-item">请选择用户</span>
							<div class="users-list"></div>
							<input type="hidden" name="uids" class="uids-input" autocomplete="off"/>
							<input type="hidden" name="users" class="users-input" autocomplete="off"/>
						</div>
					</div>
					<div class="form-item hide">
						<div class="input-label"></div>
						<div class="input-item">
							<strong>备注缺席：</strong>
							<span class="nuser-cont"></span>
						</div>
					</div>
				</div>
			</div>
			<div class="form-main">
				<div class="form-title">会议呈报</div>
			</div>
			<input type="hidden" name="mid" value="">
			<div class="form-btn-item"><button class="btn submit" type="submit">提交</button><button class="btn btn-default goback js_back1" type="button">返回</button></div>
		</form>
	</div>
</div>
<!--选择用户-->
<div class="modal fade" id="selectuser-modal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>选择用户</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
			</div>
			<div class="modal-footer">
				<button type="button" class="btn user-all">全选</button><button type="button" class="btn user-affirm">确认</button><button type="button" class="btn btn-default user-cancel" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript" src="__PUBLIC__/js/user_select.js"></script>
<script type="text/javascript">
$(function(){
	$(".js_back1").click(function(){
		window.location.href = "__APP__/Index/meeting_minutes/center_id/{$center_id}/&p={$_SESSION['page']}";
	});
	//全选
	$('body').on('click','.user-all',function(){
		$(this).addClass('user-active');
		$(this).html("取消全选");
		$('.modal-body').find('.user-checkbox').prop("checked",true);
	})
	$('body').on('click','.user-active',function(){
		$(this).removeClass('user-active');
		$(this).html("全选");
		$('.modal-body').find('.user-checkbox').removeAttr("checked");
	})
	//提交所属中心
	$("[name='center_id']").change(function(){
		var _this = $(this),
			val = _this.val();
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"center_id":val,"action":"center"},
			url:"__APP__/Index/meeting_minutes_ajax",
			success:function(data){
				if(data.module){
					var html='';
					html+= "<option value='-10'>请选择</option>";
					for(var e=0;e<data.module.length;e++){
						html+= "<option value='"+data.module[e].id+"'>";
						html+= ""+data.module[e].module_name+"";
						html+= "</option>";
					}
					$("[name='mb_id']").html(html);
				}else{
					$("[name='mb_id']").html("<option value='-10'>请先选择所属中心</option>");
				}
			}
		});
		$("[name='hy_id']").html("<option value='-10'>请选择</option>");
	})
	//提交模板
	$("[name='mb_id']").change(function(){
		var _this = $(this),
			val = _this.val();
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"mid":val,"action":"num"},
			url:"__APP__/Index/meeting_minutes_ajax",
			success:function(data){
				_this.parents('.form-item').find('.data_num').html(""+data.num+"");
				_this.parents('.form-item').find("[name='meeting_num']").val(data.num);
				var html='';
				if(data.hy){
					html+= "<option value='-10'>请选择</option>";
					for(var d=0;d<data.hy.length;d++){
						html+= "<option value='"+data.hy[d].id+"'>["+data.hy[d].meeting_num+"]"+data.hy[d].mb_name+"</option>";
					}
					$("[name='hy_id']").html(html);
				}else{
					html+= "<option value='-10'>无关联会议</option>";
					$("[name='hy_id']").html(html);
				}
			}
		});
	})
	//生成验证
	$(".click_btn").click(function(){
		var tag = true;
		
		$(".required-text").each(function(){
			var val = $(this).val();
			if(val==""){
				$(this).next(".error-item").show();
				tag = false;
			}
		});
		$(".select-add").each(function(){
			var val = $(this).val();
			if(val==-10){
				$(this).nextAll(".error-item").show();
				tag = false;
			}
		});
		if(tag){
			var mb_id = $("[name='mb_id']").val(),
				center_id = $("[name='center_id']").val(),
				mb_txt = $("[name='mb_id']").find('option:selected').html(),
				cen_txt = $("[name='center_id']").find('option:selected').html(),
				date = $("[name='date']").val(),
				meeting_address = $("[name='meeting_address']").val(),
				hy_id = $("[name='hy_id']").val();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"center_id":center_id,"mb_id":mb_id,"date":date,"hy_id":hy_id,"meeting_address":meeting_address,"action":"main_add"},
				url:"__APP__/Index/meeting_minutes_ajax",
				success:function(data){
					location.href="__APP__/Index/meeting_minutes_edit/id/"+data.mid+"/actio/add";
				}
			});
		}
	});
	
	//表单提交
	$('.submit').click(function(){
		if($('.toggle-item').size()<1){
			defeated_alert("请选择与会人员");
			return false;
		}
	})
	//隐藏错误提示
	$(document).on("focus",".required-text",function(){
		$(this).nextAll(".error-item").hide();
	});
	$(document).on("change",".select-add",function(){
		$(this).nextAll(".error-item").hide();
	});
	$(".is_all_btn").click(function(){
		$(this).siblings(".error-item").hide();
	});
});
</script>
</body>
</html>